<%@ include file="/WEB-INF/views/common/taglibs.jsp"%>

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="stylesheet" type="text/css" href="<c:url value='/stylesheets/bootstrap.min.css'/>"/>
        <link rel="stylesheet" type="text/css" href="<c:url value='/stylesheets/style.css'/>"/>        
        <title>Yichang - Sistema de comisiones</title>
        <script type="text/javascript">

        </script>        
    </head>
    <body>
        <%@ include file="/WEB-INF/views/common/header.jsp"%>
        <div>
            <div class="container">
                <h1>Reporte de comisiones</h1>
                <br/><br/>
                <div class="buscar-form">
                    <form action="<c:url value='/pages/comisiones/index'/>" method="post">
                        <table cellpadding="0" cellspacing="0" border="0">
                            <tr>
                                <td><label style="padding-right: 10px;">Empleado:</label></td>
                                <td>
                                    <c:choose>
                                        <c:when test="${not empty empleados}">
                                            <select name="empleadoId">                                                
                                                <c:forEach var="usuario" items="${empleados}">
                                                    <option value="${usuario.empleado.idEmpleado}"
                                                            ${not empty empleadoId and usuario.empleado.idEmpleado eq empleadoId ? 'selected' : ''}>
                                                        ${usuario.empleado.nombreCompleto}
                                                    </option>
                                                </c:forEach>                                                
                                            </select>
                                        </c:when>
                                        <c:otherwise>
                                            ${username}        
                                        </c:otherwise>
                                    </c:choose>
                                </td>
                                <td>
                                </td>
                            </tr>                            
                            <tr>
                                <td><label style="padding-right: 10px;">Periodo:</label></td>
                                <td>
                                    <select name="periodo">
                                        <c:forEach var="periodoItem" items="${periodos}">
                                            <option value="${periodoItem.codigoMes}"
                                                    ${not empty periodo and periodoItem.codigoMes eq periodo ? 'selected':''}

                                                    >${periodoItem.mesStr} ${periodoItem.anho}</option>    
                                        </c:forEach>
                                    </select>
                                </td>
                                <td>
                                    <input type="submit" value="Generar" class="btn btn-primary" style="margin-left: 10px;"/>
                                </td>
                            </tr>
                        </table>
                    </form>
                </div>                
                <br/>
                <h3> COMISION POR CATEGORIA </h3>
                <br/>
                <table class="table table-striped table-bordered">
                    <tr style="">
                        <th style="width: 350px;background-color: #e0e0e0;"></th>
                        <th style="width: 150px;background-color: #e0e0e0;">VENTAS</th>
                        <th style="width: 165px;background-color: #e0e0e0;">COMIS. VTA</th>
                        <th style="background-color: #e0e0e0;">FACTOR MIX % </th>
                    </tr>
                    <c:forEach var="comisionItem" items="${grupoComision.comisionVentaList}">
                        <tr>
                            <td>${comisionItem.categoria}</td>
                            <td>${comisionItem.ventaStr}</td>
                            <td>${comisionItem.comisionVentaStr}</td>
                            <td>${comisionItem.factorMixStr} %</td>
                        </tr>
                    </c:forEach>
                    <tr style="background-color: #e0e0e0;">
                        <td><b>TOTAL</b></td>
                        <td><b>S/. ${grupoComision.ventaStr}</b></td>
                        <td><b>S/. ${grupoComision.comisionVentaStr}</b></td>
                        <td><b>${grupoComision.factorMixStr} %</b></td>
                    </tr>                        
                </table>
                <br/>
                <h3> COMISION POR SUBCATEGORIA </h3>
                <br/>                        

                <c:forEach var="comisionItem" items="${grupoComision.comisionVentaList}">
                    <c:if test="${comisionItem.categoria eq 'ALIMENTOS'}">
                        <br/>         
                        <table class="table table-striped table-bordered">
                            <tr>
                                <th style="width: 350px;background-color: #e0e0e0;">${comisionItem.categoria}</th>
                                <th style="width: 150px;background-color: #e0e0e0;">VENTAS</th>
                                <th style="width: 165px;background-color: #e0e0e0;">COMIS. VTA</th>
                                <th style="background-color: #e0e0e0;">FACTOR MIX % </th>
                            </tr>
                            <c:forEach var="comisionSubItem" items="${comisionItem.comisionCategorias}">                            
                                <tr>
                                    <td>${comisionSubItem.subCategoria}</td>
                                    <td>${comisionSubItem.ventaStr}</td>
                                    <td>${comisionSubItem.comisionVentaStr}</td>
                                    <td>${comisionSubItem.factorMixFormated} %</td>
                                </tr>
                            </c:forEach>
                            <tr>
                                <td style="background-color: #e0e0e0;"><b>TOTAL</b></td>
                                <td style="background-color: #e0e0e0;"><b>S/. ${comisionItem.ventaStr}</b></td>
                                <td style="background-color: #e0e0e0;"><b>S/. ${comisionItem.comisionVentaStr}</b></td>
                                <td style="background-color: #e0e0e0;"><b>${comisionItem.factorMixStr} %</b></td>
                            </tr>                        
                        </table>                        
                        <br/>
                    </c:if>                    
                </c:forEach>

            </div>
        </div>
    </body>
</html>
